<template>
  <van-dialog
    v-model="show"
    :title="title"
    show-cancel-button
    @confirm="confirm"
  >
  </van-dialog>
</template>

<script>
export default {
  data() {
    return {
      show: false,
      row: {},
      title: '',
    }
  },
  methods: {
    open(row, act) {
      this.row = row
      this.act = act
      this.title = act == 'finish' ? '确认完成' : '确认撤销'
      this.show = true
    },
    confirm() {
      this.show = false
      this.axios.put(`/buys/${this.row.id}/${this.act}`).then(res => {
        if (res.data.code === 1) {
          const msg = this.act == 'finish' ? '已提交审核' : '已撤销'
          this.$toast.success(msg)
        } else {
          this.$notify({
            type: 'danger',
            message: res.data.msg,
          })
        }
        this.$emit('refresh')
      })
    },
  },
}
</script>

<style>
</style>